<template>
  <div>
    <mt-header title="充值记录" fixed>
      <router-link to="/" slot="left">
        <mt-button icon="back">返回</mt-button>
      </router-link>
    </mt-header>
    <div class="content">
      <ul class="item" v-for="(item, index) in list" :key="index">
        <li class="first">
          <span>充值用户：</span>
          <div class="profile">
            <img :src="item.profilePhotoPath" alt="头像" width="100%">
          </div>
          <span>{{ item.nickname }}</span>
        </li>
        <li>订单编号：{{ item.orderNumber }}</li>
        <li>充值金额：{{ item.rechargeAmount / 100 }} ￥</li>
        <li>实付款：{{ item.paymentAmount / 100 }} ￥</li>
        <li>充值日期：{{ new Date(item.gmtCreate).toLocaleString() }}</li>
        <li>处理结果：{{ status[item.status] }}</li>
        <li>如有疑问，......</li>
      </ul>
      <p class="more" v-if="more" @click="loadMore">点击加载更多...</p>
      <p class="more" style="color: #bbbec4" v-else>--全部加载完毕--</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'recharge',
  data () {
    return {
      list: [],
      pageNum: 0,
      status: ['未支付（未支付和支付失败）', '支付成功'],
      more: true
    }
  },
  methods: {
    loadMore () {
      this.pageNum++
      this.$ajax.post('/branch/user/recharge/list', {pageNum: this.pageNum, pageSize: 15})
        .then(res => {
          if (res.data.success) {
            this.list.push(...res.data.data.list)
            this.more = (res.data.data.nextPage !== 0)
          }
        })
    }
  },
  created () {
    this.loadMore()
  }
}
</script>

<style scoped>
  .content{
    margin-top: 40px;
    padding: 10px;
  }
  .more{
    text-align: center;
    color: #2d8cf0;
    margin-top: 16px;
  }
  .item{
    background-color: #fff;
    padding: 8px;
    margin-top: 16px;
    border-radius: 5px;
  }
  .item li{
    height: 26px;
    line-height: 26px;
  }
  .item li.first{
    height: 36px;
    line-height: 36px;
    overflow: hidden;
  }
  .item li.first span{
    display: inline-block;
    line-height: 36px;
    float: left;
  }
  .profile{
    width: 36px;
    height: 36px;
    border-radius: 100%;
    float: left;
    overflow: hidden;
  }
</style>
